/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.bolsaTrabajo.model.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sysmanager
 */
@Entity
@Table(catalog = "bolsadetrabajo", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Postulacion.findAll", query = "SELECT p FROM Postulacion p"),
    @NamedQuery(name = "Postulacion.findByIdDetallePost", query = "SELECT p FROM Postulacion p WHERE p.idDetallePost = :idDetallePost"),
    @NamedQuery(name = "Postulacion.findByFechahora", query = "SELECT p FROM Postulacion p WHERE p.fechahora = :fechahora")})
public class Postulacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_detalle_post", nullable = false)
    private Integer idDetallePost;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechahora;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDetallePost", fetch = FetchType.LAZY)
    private Collection<MensajePostulacion> mensajePostulacionCollection;
    @JoinColumn(name = "id_publicacion", referencedColumnName = "id_publicacion", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Publicacion idPublicacion;
    @JoinColumn(name = "id_persona", referencedColumnName = "id_persona", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Persona idPersona;

    public Postulacion() {
    }

    public Postulacion(Integer idDetallePost) {
        this.idDetallePost = idDetallePost;
    }

    public Postulacion(Integer idDetallePost, Date fechahora) {
        this.idDetallePost = idDetallePost;
        this.fechahora = fechahora;
    }

    public Integer getIdDetallePost() {
        return idDetallePost;
    }

    public void setIdDetallePost(Integer idDetallePost) {
        this.idDetallePost = idDetallePost;
    }

    public Date getFechahora() {
        return fechahora;
    }

    public void setFechahora(Date fechahora) {
        this.fechahora = fechahora;
    }

    @XmlTransient
    public Collection<MensajePostulacion> getMensajePostulacionCollection() {
        return mensajePostulacionCollection;
    }

    public void setMensajePostulacionCollection(Collection<MensajePostulacion> mensajePostulacionCollection) {
        this.mensajePostulacionCollection = mensajePostulacionCollection;
    }

    public Publicacion getIdPublicacion() {
        return idPublicacion;
    }

    public void setIdPublicacion(Publicacion idPublicacion) {
        this.idPublicacion = idPublicacion;
    }

    public Persona getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(Persona idPersona) {
        this.idPersona = idPersona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetallePost != null ? idDetallePost.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Postulacion)) {
            return false;
        }
        Postulacion other = (Postulacion) object;
        if ((this.idDetallePost == null && other.idDetallePost != null) || (this.idDetallePost != null && !this.idDetallePost.equals(other.idDetallePost))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sv.com.bolsaTrabajo.controller.Postulacion[ idDetallePost=" + idDetallePost + " ]";
    }
    
}
